#ifndef __INF_DS1302_H__
#define __INF_DS1302_H__

#include "main.h"

/* 星期枚举 */
typedef enum{
    Monday = 1,
    Tuesday,
    Wednesday,
    Thursday,
    Friday,
    Saturday,
    Sunday
}Week_t;

/* 时间结构体 */
typedef struct{
    uint8_t second;
    uint8_t minute;
    uint8_t hour;
    uint8_t date;
    uint8_t month;
    uint8_t year;
    Week_t day;
}datetime_t;

/* 寄存器地址宏定义(都是写寄存器,读寄存器地址加1) */
#define DS1302_Seconds_Reg 0x80
#define DS1302_Minutes_Reg 0x82
#define DS1302_Hour_Reg    0x84
#define DS1302_Date_Reg    0x86
#define DS1302_Month_Reg   0x88
#define DS1302_Day_Reg     0x8A
#define DS1302_Year_Reg    0x8C
#define DS1302_WP_Reg      0x8E
#define DS1302_TCSDS_Reg   0x90

/**
 * @brief 读取时间
 * @param time 时间结构体
 */
void Inf_DS1302_ReadTime(datetime_t *time);

/**
 * @brief 写入时间
 * @param time 时间结构体
 */
void Inf_DS1302_WriteTime(datetime_t *time);

#endif
